//
//  Hot_TableViewCell.m
//  EggSteward
//
//  Created by 王道林 on 16/8/31.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "Hot_TableViewCell.h"
#import "BaseLabel.h"
#import "Masonry.h"
#import "Home_NewsModel.h"
#import "UIImageView+WebCache.h"
@interface Hot_TableViewCell ()
@property (nonatomic, strong) UIImageView *imageview;
@property (nonatomic, strong) BaseLabel *labelTitle;
@property (nonatomic, strong) BaseLabel *labelContect;
@end

@implementation Hot_TableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)createSubview
{
    _imageview = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageview];
    _imageview.backgroundColor = [UIColor redColor];
    
    _labelTitle = [[BaseLabel alloc] init];
    _labelTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    _labelTitle.numberOfLines = 0;
    [self.contentView addSubview:_labelTitle];
    
    _labelContect = [[BaseLabel alloc] init];
    _labelTitle.numberOfLines = 0;
    [self.contentView addSubview:_labelContect];
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    [_imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(8);
        make.top.mas_equalTo(self.contentView.mas_top).mas_offset(8);
        make.height.mas_equalTo(self.contentView.mas_height).mas_offset(-16);
        make.width.mas_equalTo(self.contentView.mas_height).mas_offset(-16);
    }];
    [_labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_imageview.mas_right).mas_offset(8);
        make.top.mas_equalTo(self.contentView.mas_top).mas_offset(8);
        make.height.mas_equalTo(_imageview.mas_height).multipliedBy(0.3);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-10);
    }];
    [_labelContect mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_imageview.mas_right).mas_offset(8);
        make.top.mas_equalTo(_labelTitle.mas_bottom);
        make.height.mas_equalTo(_imageview.mas_height).multipliedBy(0.7);
        make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10);
    }];
}

- (void)setModel:(Home_NewsModel *)model
{
    _model = model;
    _labelTitle.text = _model.cms_title;
    _labelContect.text = _model.descriptions;
    [_imageview sd_setImageWithURL:[NSURL URLWithString:_model.cms_pic] placeholderImage:[UIImage imageNamed:@"114"]];
    
}


@end
